<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <canvas width="600" height="300"></canvas>
  <script src="/js/mesh.js"></script>
  <script>
    const {Figure2D, Mesh2D, Renderer} = meshjs;

    const canvas = document.querySelector('canvas');

    const figure = new Figure2D();
    figure.rect(0, 0, 200, 200);
    figure.normalize(...figure.boundingCenter);

    const mesh1 = new Mesh2D(figure);
    const mesh2 = new Mesh2D(figure);

    mesh1.setFill({
      color: [1, 0, 0, 0.5],
    });

    mesh2.setFill({
      color: [0, 0, 1, 0.5],
    });

    mesh2.rotate(Math.PI / 4);

    mesh1.translate(300, 150);
    mesh2.translate(300, 150);

    const renderer = new Renderer(canvas);

    renderer.drawMeshes([mesh1, mesh2]);
  </script>
</body>
</html>